/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aptech.DAO;
import com.aptech.model.Bank;
import com.aptech.model.DirectoryCategories;
import com.aptech.model.RealEstateType;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author Hoang Quy Hong An
 */
public class DirectoryCategoriesDAO {
 private  Connection myCon = null;
    private  PreparedStatement ps = null;
    private  ResultSet rs = null;
    private String strCommand = "";

    public  ArrayList<DirectoryCategories> getAllDirectoryCategories() {
        ArrayList<DirectoryCategories> listDirectoryCategories = new ArrayList<DirectoryCategories>();
        DirectoryCategories objDirectoryCategories = null;
        strCommand = "SELECT directoryCategoryID ,directory_categoryName "+
        "FROM tbl_DirectoryCategories WHERE diCategoriesStatus = 1";
        try {
            myCon = myConnection.getConnection();
            ps = myCon.prepareStatement(strCommand, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs = ps.executeQuery();
            while (rs.next()) {
                objDirectoryCategories = new DirectoryCategories();
                objDirectoryCategories.setDirectoryCategoryID(rs.getInt("directoryCategoryID"));
                objDirectoryCategories.setDirectory_categoryName(rs.getString("directory_categoryName"));
                listDirectoryCategories.add(objDirectoryCategories);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myConnection.closeConnection(myCon, ps, rs);
        }
        return listDirectoryCategories;
    }
}
